//
//  ViewController.m
//  02-UIViewController
//
//  Created by Snow on 16/7/15.
//  Copyright © 2016年 Snow. All rights reserved.
//

#import "ViewController.h"
#import "PresentViewController.h"

@interface ViewController ()
@property (nonatomic, strong) UIView *subView;
@end

@implementation ViewController
//1.初始化
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        //不要在这个方法中加载视图
        //在这个方法中去初始化一些数据相关的内容
    }
    return self;
}
//loadView 加载view
//UINavigationCOntroller
//UitableViewController 在loadView中给重写赋值
- (void)loadView
{
    [super loadView];
}
//懒加载
- (UIView *)subView
{
    if (_subView == nil) {
        _subView = [UIView new];
    }
    return _subView;
}
//已经 加载
//所有自定义视图的创建
- (void)viewDidLoad {
    [super viewDidLoad];
//    NSLog(@"viewDidLoad");
//    self.view = nil;
//    NSLog(@"%@", self.view);
    //init loadView viewdidload 只走一次
    self.view.backgroundColor = [UIColor yellowColor];
    
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    [super touchesBegan:touches withEvent:event];
    PresentViewController *present = [[PresentViewController alloc] init];
    //莫泰 动画效果
    //    UIModalTransitionStyleCoverVertical = 0,
    //UIModalTransitionStyleFlipHorizontal 默认效果
    //UIModalTransitionStyleCrossDissolve,左右旋转翻页
    //UIModalTransitionStylePartialCurl渐变效果
    //UIModalTransitionStyle翻书效果
    present.modalTransitionStyle = UIModalTransitionStylePartialCurl;
    [self presentViewController:present animated:YES completion:nil];
}
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    [self dismissViewControllerAnimated:YES completion:nil];
}
//下述方法会执行很多次
//视图将要出现时
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
}
//视图已经出现时
- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
}
//视图将要消失时
- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
}
//视图已经消失时
- (void)viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
}
//接受到内存警告时 执行的方法
- (void)didReceiveMemoryWarning {
    //从父类继承的方法中有对内存警告的打印
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
//释放部分内存
    //把为显示在屏幕上单饿资源清空
}

@end
